﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Trans.system
{
    public partial class Sys_restore : Form
    {
        public Sys_restore()
        {
            InitializeComponent();
        }

        private void bt_file_Click(object sender, EventArgs e)
        {
            OpenFileDialog f = new OpenFileDialog();
            if (f.ShowDialog() == DialogResult.OK) 
            {
                tx_file.Text = f.FileName;
            }            
        }

        private void bt_cancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void bt_restore_Click(object sender, EventArgs e)
        {

            if (
                            MessageBox.Show(
                                "还原后现有数据将丢失，确定?",
                                "提示",
                                MessageBoxButtons.OKCancel,
                                MessageBoxIcon.Warning) == DialogResult.OK)
            {
                
            }
            else return;
            
            bt_restore.Text = "还原中...";
            try
            {


                sysAdapter.Restore(tx_file.Text);
                MessageBox.Show(
                                "还原完成",
                                "",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
            }
            catch (Exception ee)
            {
                MessageBox.Show(
                                "还原失败"+ee.Message,
                                "",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }
    }
}
